#pragma once
#ifndef __CMemoryMappedFile
#define __CMemoryMappedFile
#include <boost/interprocess/file_mapping.hpp>
#include <boost/interprocess/mapped_region.hpp>

class CMemoryMappedFile
{
public:
	CMemoryMappedFile();
	CMemoryMappedFile(const char* sFileName, unsigned long mapSize = 0);
	~CMemoryMappedFile();
	bool OpenFile(const char* sFileName, unsigned long mapSize = 0);
	unsigned long GetFileSize(const char* sFileName);
	void* MapFileRegion(unsigned long ulStart = 0, unsigned long ulSize = 0);
	void* GetPointer(unsigned long ulOffset = 0);
private:
	unsigned long m_ulFileSize, m_ulMapDelta, m_ulMapSize;
	void* m_pData;
  boost::interprocess::file_mapping* m_pFile;
	boost::interprocess::mapped_region* m_pMap;
	void CloseMap();
};
#endif // __CMemoryMappedFile
